package com.pro.service.impl;

import com.pro.bean.PageGoods;
import com.pro.bean.PageUser;
import com.pro.bean.Sign;
import com.pro.bean.UserInfo;
import com.pro.dao.UserInfoDao;
import com.pro.service.UserInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
/**
 *UserInfo服务层实现类
 **/
@Service
public class UserInfoServiceImpl implements UserInfoService {
    //注入UserInfoDao接口
    @Autowired
    private UserInfoDao userInfoDao;

    /**
     * 查询表中所有数据
     *
     **/
    public List<UserInfo> all() {
        return userInfoDao.all();
    }

    //用户登录
    @Override
    public UserInfo login(String userName) {
        return userInfoDao.login(userName);
    }
    //根据用户名查询数据库是否有该用户数据
    @Override
    public String selName(String userName) {
        return userInfoDao.selName(userName);
    }
    //用户注册
    @Override
    public int add(UserInfo userInfo) {
        return userInfoDao.add(userInfo);
    }

    @Override
    public int selVipStatus(int userId) {
        return userInfoDao.selVipStatus(userId);
    }

    @Override
    public int userInfoUpdate(UserInfo userInfo) {
        return userInfoDao.userInfoUpdate(userInfo);
    }

    @Override
    public int cancel(int id) {
        return userInfoDao.cancel(id);
    }

    @Override
    public PageUser page(int pageIndex, int size) {
        return new PageUser(
                pageIndex,
                userInfoDao.count(),
                userInfoDao.page((pageIndex - 1) * size, size)
        );
    }

    @Override
    public Sign integral(int userId) {
        return userInfoDao.integral(userId);
    }

    @Override
    public int upBalance(Double balance, int id) {
        return userInfoDao.upBalance(balance,id);
    }


}
